<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>全局默认配置</title>
    <script src="./lib/axios.min.js"></script>
</head>
<body>
    <button>发送请求1</button>
    <button>发送请求2</button>
</body>
<script>
    const btns = document.querySelectorAll("button");
	axios.defaults.baseURL = "http://zhangpeiyue.com";
	axios.defaults.headers = {
		token:100
    }
	axios.defaults.params = {
		age:12
    }

	btns[0].onclick = async function(){
		// 当请求地址写的不是完整地址，那么会与默认配置中的baseURL进行拼接。
		const {data} = await axios.get("http://127.0.0.1/scoreList/1");
		console.log(data);
    }

	btns[1].onclick = async function(){
		const {data} = await axios.get("/scoreList/2");
		console.log(data);
    }
</script>
</html>